﻿@{
    ViewBag.Title = "Index";
}
   @Scripts.Render("~/bundles/zTree_v3")
     @Styles.Render("~/zTree_v3/css")

@*    <link href="@Url.Content("~/Scripts/zTree_v3/css/demo.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Scripts/zTree_v3/css/zTreeStyle/zTreeStyle.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/zTree_v3/js/jquery-1.4.4.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/zTree_v3/js/jquery.ztree.core-3.5.js")" type="text/javascript"></script>*@

    <script type="text/javascript">

        //function click_a(divDisplay)
        //{
        //    if (document.getElementById(divDisplay) == "create")
        //    {

        //        document.getElementById(edit).style.display = " none";
        //        document.getElementById(deleteitem).style.display = "none";
        //    }

        //    else if (document.getElementById(divDisplay) == "edit") {
        //        document.getElementById(create).style.display = "none";
        //        document.getElementById(deleteitem).style.display = "none";

        //    }
        //    else {

        //        document.getElementById(create).style.display = "none";
        //        document.getElementById(edit).style.display = "none";

        //    }
        //}
   
        $(document).ready(function () {
            $.ajax({
                type: "Get",
                url: "@Url.Action("getmenu","Category")",
                async: false,
                cache:false,
                success: function (data) {
                    tree=$.fn.zTree.init($("#treeDemo"), setting, data);
                    tree.expandAll(true);
                }
            });
        })
        var setting = {
            data: {
                simpleData: {
                    enable: true
                }
            },
                callback: {
                    onClick: zTreeOnClick
                }
            };

        function zTreeOnClick(event, treeId, treeNode) {


            //$.post("Category/Edit/", "ID=" +1, function (data) {
            //    $("#edit").html(data);//这里是重点，右侧数据获取后要显示到div中
            //}, "text"
            //);
            //return false;
            @*@Url.Action("Edit", "Category", new { ID =t});  *@

            //"#createcategory"
@*            var tid = treeNode.treeId;
            var rootUrl = '@Url.Action("Edit","Category")';
            $("#edit").load(rootUrl);*@
          //  $(function () {s
            $.ajax({
                type: "post",
                async: false,
                      url:'/Category/Edit/',
                    //  data: { ID: treeNode.treeId },
                      data: "ID="+treeNode.id,
                      success: function (data) {
                          $("#edit").html(data);          
                      } });
      //      })
                  //alert("选择成功！");
                    }

        //function zTreeOnClick(event, treeId, treeNode) {
        //    alert(treeNode.tId + " ," + treeNode.linkUrl);
        //};

    </script>
<div id="main">
    @* @Html.ActionLink(" 新增",)*@
    <div class="row">
        <div class="col-xs-12 col-sm-5">
            @Html.ActionLink(" 新增一级菜单", "Create", new { onclick = "return click_a('edit')" })
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12 col-sm-5">
            <div class="zTreeDemoBackground left">
                <ul id="treeDemo" class="ztree"></ul>
            </div>
        </div>
        <div class="col-xs-12 col-sm-5" style="padding-top:7px;">
            <div id="edit">
                @{Html.Action("Edit");}
            </div>
        </div>
    </div>
</div>

<script>
    $("#carousel-hm").css("display", "none");
    $("#f3 a").html("<font> " + $("#f3 a").text() + " </font>")
    $("#f3 a").addClass("selected");
</script>